package com.jscm.showAttribute;

import com.jscm.showHexBool.HexBoolWindow;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;

public class OpenAttrBtn {
    public static Button button = new Button();
    static {
        init();
    }
    public static void init(){
        button.setPrefWidth(40);
        button.setPrefHeight(40);
        button.setBackground(new Background(new BackgroundImage(new Image("btn/btn8.png"), BackgroundRepeat.NO_REPEAT ,BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, BackgroundSize.DEFAULT)));
//        打开特征抓取窗口
        button.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                if(!AttributeWindow.stage.isShowing()){
                    AttributeWindow.stage.show();
                }else {
                    AttributeWindow.stage.hide();
                }
            }
        });
        button.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                button.setStyle("-fx-border-radius: 5px;-fx-border-color: #ffffff");
            }
        });
        button.setOnMouseExited(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                button.setStyle("-fx-border-radius: none");
            }
        });
    }
}
